<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head lang="en">
    <meta charset="UTF-8">
    <title>泽晋书城首页</title>
    <link rel="stylesheet" type="text/css"  href="dist/css/bootstrap.min.css" th:href="@{/dist/css/bootstrap.min.css}">
    <link rel="stylesheet" type="text/css" href="css/index.css" th:href="@{/css/index.css}" />
    <link rel="stylesheet" type="text/css" href="css/animate.css" th:href="@{/css/animate.css}" />
    <script src="../static/echarts.min.js" th:src="@{/echarts.min.js}"></script>
</head>
<body>
<!--导航部分 替换common begin-->
<div th:replace="common/header :: header"></div>
<!--导航部分 end-->
<!--最顶端轮播图片 begin-->
<div th:replace="common/carousel :: carousel"></div>
<!--最顶端轮播图片 end-->
<div class="container">
    <ol class="breadcrumb">
        <li><a href="#">图书列表</a></li>
    </ol>
</div>
<!--图书内容部分 begin-->
<div class="container">
    <div class="row">
        <div class="col-sm-6 col-md-3 " th:each="book:${bookList1}">
            <div class="thumbnail">
                <a href="details.html" th:href="@{/book/detail(id=${book.id})}"><img src="images/beiwei78.jpg" th:src="@{'/public/' + ${book.imgUrl}}" alt="通用的占位符缩略图"></a>
                <div class="caption">
                    <h3 th:classappend="h3-height" th:text="${book.name}">北纬78°</h3>
                    <p th:classappend="p-height">价格:<span th:text="${book.newPrice}">19.5</span>元&nbsp;&nbsp;作者:<span th:text="${book.author}">陈丹燕</span>&nbsp;&nbsp;</p>
                    <p>
                        <a href="details.html" th:href="@{/book/detail(id=${book.id})}">
                            更多信息
                        </a>
                    </p>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="container">
    <ul class="pager">
        <li th:classappend="${cur == 1} ? 'disabled' : ''">
            <a th:style="${cur == 1} ? 'pointer-events:none' : ''" href="javascript:void(0)" th:onclick="|loadData(${pre})|">&larr;上一页</a>
        </li>
        <li th:classappend="${cur == last} ? 'disabled' : ''" >
            <a th:style="${cur == last}  ? 'pointer-events:none' : ''" href="javascript:void(0)" th:onclick="|loadData(${next})|">下一页 &rarr;</a>
        </li>

    </ul>
</div>
<!--首页底部信息 begin-->
<div th:replace="common/footer :: footer"></div>
</div>


<div th:replace="common/bookModal :: bookModal"></div>

</body>

<script src="dist/js/jquery.min.js" th:src="@{/dist/js/jquery.min.js}"></script>
<script src="js/carousel.js" th:src="@{/js/carousel.js}" type="text/javascript" charset="utf-8"></script>
<script src="dist/js/bootstrap.min.js" th:src="@{/dist/js/bootstrap.min.js}"></script>
<script src="js/wow.js" th:src="@{/js/wow.js}"></script>
<script src="js/cha.js" th:src="@{/js/cha.js}"></script>

<script th:src="@{/js/login_reg.js}"></script>
<script th:inline="javascript">
    //获取应用路径
    var contextPath = [[${#request.getContextPath()}]];
</script>
<script type="text/javascript">
    if(!(/msie [6|7|8|9]/i.test(navigator.userAgent))) {
        new WOW().init();
    };

    $(function () {
        $("#selected").load(contextPath + "/book/getBookData",buildQuery(1,1));
        $("#recommend").load(contextPath + "/book/getBookData",buildQuery(1,2));
        $("#bargain").load(contextPath + "/book/getBookData",buildQuery(1,3));
    })

    //添加图书
    function addbook() {
        var datas = $("#addForm").serialize();
        $.ajax({
            url: contextPath + "/book/add",
            data:datas,
            method:"post",
            success:function (data) {
                if(data != null){
                    alert(datas)
                    alert("添加成功！点此返回");
                    window.location.href = contextPath + "/book/index";
                }
            }
        })
    }

    //包装查询参数
    function buildQuery(page,category) {
        var query = {};
        query.page = typeof page == "undefined" ? 1 : page;
        query.category = category;
        return query;
    }


</script>
</html>